﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    function addDept() {
        $.ajax({
            type: "GET",
            url: "/Basic/AddDept",
            success: function(data) {
                addtab("7-1", "添加部门");
                $("#workarea-7-1").html(data);
            }
        });
    }
    $(function() {
        tableSelectOrder("#alldeptlist .table_style");
    })

    function deptinfoshow(deptid) {
        $.ajax({
            type: "POST",
            url: "/Basic/DeptInfo",
            data: { "deptid": deptid },
            success: function(data) {
                addtab('7-2-1', '部门信息');
                $("#workarea-7-2-1").html(data);
            }
        })
    }

</script>

<div id="alldeptlist">
    <div>
        <input class="btn_style" type="button" value="添加部门" onclick="addDept()" style="margin-top: 5px;" />
    </div>
    <div id="dtdeptlist" style="margin-top: 5px;">
        <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th>
                        名称
                    </th>
                    <th>
                        分类
                    </th>
                    <%--     <th>
                    状态
                </th>--%>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    System.Data.DataTable dt = ViewData["dt"] as System.Data.DataTable;
                    if (dt.Rows.Count == 0)
                    { 
                %>
                <tr>
                    <td colspan="0" style="text-align: center;">
                        当前无数据！
                    </td>
                </tr>
                <%
                    }
                    else
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                %>
                <tr>
                    <td>
                        <%=dt.Rows[i]["部门名称"]%>
                    </td>
                    <td>
                        <%=dt.Rows[i]["分类"]%>
                    </td>
                    <%--     <td>
                    <%=dt.Rows[i]["状态"]%>
                </td>--%>
                    <td>
                        <a onclick="deptinfoshow(<%=dt.Rows[i]["部门编码"] %>)">查看</a>
                    </td>
                </tr>
                <%
                    }
                    }%>
            </tbody>
        </table>
    </div>
    <div id="pageLink">
        <%var pageInfo = ViewData["PagingInfo"] as PagingInfo; %>
        <%if (pageInfo != null)
          { %>
        <%=Ajax.PageLinks(pageInfo, index => Url.Action("AllDeptList", new { page = index }), new AjaxOptions { UpdateTargetId = "alldeptlist" })%>
        <%} %>
    </div>
</div>
